package com.spic.business.mountguard.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import com.spic.business.mountguard.domain.MountSignRecord;
import com.spic.business.mountguard.service.IMountSignRecordService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * 上岗到位签到记录Controller
 * 
 * @author spic
 * @date 2021-12-06
 */
@RestController
@RequestMapping("/mountguard/record")
public class MountSignRecordController extends BaseController
{
    @Autowired
    private IMountSignRecordService mountSignRecordService;

    /**
     * 查询上岗到位签到记录列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:list")
    @GetMapping("/list")
    public TableDataInfo list(MountSignRecord mountSignRecord)
    {
        startPage();
        List<MountSignRecord> list = mountSignRecordService.selectMountSignRecordList(mountSignRecord);
        return getDataTable(list);
    }

    /**
     * 导出上岗到位签到记录列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:export")
    @Log(title = "上岗到位签到记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MountSignRecord mountSignRecord) throws IOException
    {
        List<MountSignRecord> list = mountSignRecordService.selectMountSignRecordList(mountSignRecord);
        ExcelUtil<MountSignRecord> util = new ExcelUtil<MountSignRecord>(MountSignRecord.class);
        util.exportExcel(response, list, "上岗到位签到记录数据");
    }

    /**
     * 获取上岗到位签到记录详细信息
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(mountSignRecordService.selectMountSignRecordById(id));
    }

    /**
     * 新增上岗到位签到记录
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:add")
    @Log(title = "上岗到位签到记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MountSignRecord mountSignRecord)
    {
        return toAjax(mountSignRecordService.insertMountSignRecord(mountSignRecord));
    }

    /**
     * 修改上岗到位签到记录
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:edit")
    @Log(title = "上岗到位签到记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MountSignRecord mountSignRecord)
    {
        return toAjax(mountSignRecordService.updateMountSignRecord(mountSignRecord));
    }

    /**
     * 删除上岗到位签到记录
     */
    @PreAuthorize(hasPermi = "business/mountguard:record:remove")
    @Log(title = "上岗到位签到记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mountSignRecordService.deleteMountSignRecordByIds(ids));
    }
}
